package com.cndw.kungfu.model;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.cndw.kungfu.dao.ConfigDao;
import com.cndw.kungfu.dao.IBusinessDao;
import com.cndw.kungfu.dao.SimpleModuleDao;
import com.cndw.kungfu.domain.LevelUpgrade;
import com.cndw.kungfu.domain.Notice;
import com.cndw.kungfu.domain.Script;
import com.cndw.kungfu.domain.Story;
import com.cndw.kungfu.domain.Undercity;
import com.cndw.kungfu.domain.Vocation;

/**
 * 获取无分类的配置
 * @author fantadust
 * @date 2011-4-29 下午04:38:40
 */
@Component
public class SimpleModuleManager {

	@Autowired
	private SimpleModuleDao dao;
	@Autowired
	private ConfigDao configDao;
	@Autowired
	private IBusinessDao businessDao;

	
	
	
	
	/**
	 * 获取系统职业配置
	 * @return
	 */
	public Map<Integer, Vocation> getVocationConfigFromDb(){
		try {
			List<Vocation> vocations =  dao.selectVocation();
			Map<Integer, Vocation> map = new HashMap<Integer,Vocation>();
			for(Vocation e:vocations){
				map.put(e.getId(), e);
			}
			return map;			
		} catch (Exception e) {
			return null;
		}
	}
	
	/**
	 * 获取脚本列表
	 * @return
	 */
	public Map<Integer, Script> getScriptConfigFromDb(){
		try {
			List<Script> Scripts =  dao.selectScript();
			Map<Integer, Script> map = new HashMap<Integer,Script>();
			for(Script e:Scripts){
				map.put(e.getId(), e);
			}
			return map;			
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}		
		
	}
	/**
	 * 获取全部副本
	 * @return
	 */
	public List<Undercity> getUnderCitiesFromDb(){
		return dao.selectUndercity();
	}

	
	/**
	 * 获取系统关键配置
	 * @return
	 */
	public Map<String, String> loadConfigFromDb(){
		try {
			return configDao.loadConfig();
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
	
	public List<Notice> loadBusinessNoticesFromDb (){
		try {
			return businessDao.loadBusinessNotices();
		} catch (Exception e) {
			return null;
		}
	}

	public Map<Integer, LevelUpgrade> getLevelUpgradeMapDB() {
		try {
			return dao.selectLevelUpgread();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	
	public Map<Integer, Story> getStoryMapDB(){
		try {
			return dao.getStoryMap();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	


	
}
